/*
 * @lc app=leetcode.cn id=125 lang=javascript
 *
 * [125] 验证回文串
 */

// @lc code=start

/**
 * @param {string} s
 * @return {boolean}
 */
var isPalindrome = function (s) {
  if (s.length < 2) {
    return true;
  }

  // 判断字符串是否为数字和字母组合
  // const validate = (str) => /^[0-9a-zA-Z]*$/.test(str);
  s = s.replace(/[\W|_]/g, "").toLowerCase();

  for (let i = 0, j = s.length - 1; i < j; i++, j--) {
    let left = s[i];
    let right = s[j];
    if (left !== right) {
      return false;
    }
  }

  return true;
};
// @lc code=end
